tests: Add example file validation test suite.#213
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds a new pytest suite to validate Python example files under lib/*/examples/, aiming to catch syntax issues, missing final newlines, bare except:, and calls to driver methods that don’t exist in the corresponding device.py.
Changes:
- Introduces
tests/test_examples.pyto discover and validate all driver example scripts. - Implements AST-based checks for bare
except:and driver method-call validity. - Adds file-level checks for Python compilation and final newline presence.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
All 5 Copilot comments addressed in fde1f76:
|
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #212
Summary
Add
tests/test_examples.py— a test suite that validates all example files inlib/*/examples/. Can be run in CI alongside existing mock tests.What it checks
For each example file (51 files across 15 drivers):
\nexcept Exception:per project conventiondevice.pyResults on current main
Pre-existing bugs detected
lib/lis2mdl/examples/magnet_test.pymag.read_reg()— method is_read_reg()(private)lib/wsen-pads/examples/test.pysensor._read_u8()— method doesn't existThese are tracked in issue #212 and should be fixed separately.
CI integration
Add to the test workflow: